from django.utils.deprecation import MiddlewareMixin
class UserAgentMiddleware(MiddlewareMixin):
    def process_request(self, request):
        print(f"UserAgentMiddleware处理请求")
        pass

    def process_response(self, request, response):
        print(f"UserAgentMiddleware处理响应")
        print(f"检测到请求工具",request.headers['User-Agent'])
        return response